const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
  app.use(
    '/api',
    createProxyMiddleware({
      target: 'http://localhost:5000',
      changeOrigin: true,
      pathRewrite: {
        '^/api' : '/'
      }
    })
  );

  app.use(
    '/chouti-imgs',
    createProxyMiddleware({
      target: 'https://img3.chouti.com',
      changeOrigin: true,
      pathRewrite: {
        '^/chouti-imgs' : '/'
      },
      headers: {
        "Referer": "https://dig.chouti.com"
      }
    })
  );
};
